package com.zgzg.shop.pay.base.enums;

/**
 * @author: lzg
 * @description:
 */
public enum ApiCode {
    /**
     * 成功
     */
    OK(200, "SUCCESS"),
    SERVER_ERROR(100001, "服务器内部错误"),
    SERVICE_HANDLE_FAIL(100003, "业务处理失败"),
    PUSH_FAIL(100004, "推送失败"),
    PUSH_EXCEPTION(100005, "推送发生异常"),
    CREATE_AUTH_FAIL(100006, "生成签名失败"),
    SERVER_RESPONSE_BODY_NULL(100007, "服务器响应为空"),
    INTERNAL_SERVER_ERROR(10300, "服务器处理失败"),
    PUSH_FAIL_PARTIAL(100008, "部分推送失败"),
    AUTH_IS_NULL(100009, "签名未设置"),
    AUTH_NOT_MATCH(100010, "签名不匹配"),
    PLUGIN_BEAN_REGISTER_DUPLICATION(101, "插件注册，beanName重复，请检查配置"),
    PLUGIN_BEAN_REGISTER_EXCEPTION(102, "插件注册失败"),
    INVALID_PARAMETER(10100, "参数丢失或者参数不合法"),
    INVALID_PARAMETER_CHECK(10101, "参数解析失败，原因：存在与接口文档不匹配的参数，请按接口文档检查入参"),
    ;

    private Integer code;
    private String msg;
    ApiCode(int code, String message) {
        this.code = code;
        this.msg = message;
    }
    public Integer getCode() {
        return code;
    }
    public String getMsg() {
        return msg;
    }

    public static ApiCode of(int code) {
        for (ApiCode apiCode : ApiCode.values()) {
            if (apiCode.getCode() == code) {
                return apiCode;
            }
        }
        return null;
    }
}

